/*
 * This class outlines what will be shown on the first splash screen
 */
package qq.LSG.game.cloudfactory.screens;

import qq.LSG.game.cloudfactory.CloudFactoryGame;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Rectangle;

public class SplashScreen2 implements Screen {
	
	Texture splashImage;
	Rectangle splashScreen;
	OrthographicCamera camera;
	SpriteBatch batch;
	CloudFactoryGame cFactory; 
	
	public SplashScreen2(CloudFactoryGame game) {
		this.cFactory = game;
	}
	
	@Override
	public void render(float delta) {
		Gdx.gl.glClearColor(0.1f,0.2f,0.2f,1); // Parameters = R, G, B, Alpha
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		
		camera.update();
		
		batch.setProjectionMatrix(camera.combined);
		batch.begin();
		batch.draw(splashImage, splashScreen.x, splashScreen.y);
		batch.end();
		
		if (Gdx.input.isTouched())
			cFactory.setScreen(cFactory.mainMenu);
	}

	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void show() {
		// Set the camera to 800x480
		// TODO Make a view package!
		camera = new OrthographicCamera();
		camera.setToOrtho(false, 800, 480);
		
		// Create a new spritebatch
		batch = new SpriteBatch();
		
		// Load the splash png
		splashImage = new Texture(Gdx.files.internal("data/thank.png"));
		
		// Rectangle is used to represent the splash screen
		// TODO Is there something better than rectangles for our splash screen?
		splashScreen = new Rectangle();
		splashScreen.x = 800 / 2 - 48 / 2;
		splashScreen.y = 20;
		splashScreen.width = splashImage.getWidth();
		splashScreen.height = splashImage.getHeight();
		
		
	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		splashImage.dispose();
		batch.dispose();
	}

}
